//
//  CustomerTableHeader.m
//  Rabbit
//
//  Created by 阿帕 on 2018/11/12.
//  Copyright © 2018年 GCY. All rights reserved.
//

#import "CustomerTableHeader.h"

@interface CustomerTableHeader ()

//@property (strong , nonatomic)UIImageView *topBgImageView;

@end

@implementation CustomerTableHeader

#pragma mark - Intial
- (instancetype)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    if (self) {
        
        [self setUpUI];
    }
    return self;
}

- (void)setUpUI {
    
    UIImageView *topBgImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, self.cy_width - 20, self.cy_height - 20)];
//    topBgImageView.contentMode = UIViewContentModeScaleAspectFit;
    topBgImageView.image = image(@"img_customer_topBg");
    [self addSubview:topBgImageView];
    
    NSArray *titles = @[@"客户人数（人）", @"昨日新增（人）", @"本月客户核卡（张）", @"昨日客户核卡（张）"];
    
    for (int i=0; i<titles.count; i++) {
        
        int x = i%2;
        int y = i/2;
        
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(20 + topBgImageView.cy_width/2 * x, 15 + 80 * y, topBgImageView.cy_width/2 - 10, 15)];
        label.font = font(11);
        label.textColor = [UIColor whiteColor];
        label.text = titles[i];
        [topBgImageView addSubview:label];
        
        UILabel *valueLabel = [[UILabel alloc] initWithFrame:CGRectMake(20 + topBgImageView.cy_width/2 * x, 35 + 80 * y, topBgImageView.cy_width/2 - 10, 25)];
        valueLabel.tag = 50 + i;
        valueLabel.font = [UIFont boldSystemFontOfSize:15];
        valueLabel.textColor = [UIColor whiteColor];
        [topBgImageView addSubview:valueLabel];
    }
}

- (void)setValueArray:(NSArray *)valueArray {
    
    _valueArray = valueArray;
    
    for (int i=0; i<_valueArray.count; i++) {
        UILabel *valueLabel = [self viewWithTag:50 + i];
        valueLabel.text = [NSString stringWithFormat:@"%@", _valueArray[i]];
    }
}

@end
